package info.casel.tulebox;
import java.util.Random;

import com.opensymphony.xwork2.ActionSupport;

/**
 * @author Casel
 * Generate 2 diferent kinds of names
 * @thanks Enrico for the idea of Integer silabas.
 *
 */
public class Names extends ActionSupport {
	
    private Integer silabas = 2;
    private Integer raza = 0;
   	private String name = "";
   	private String[] inicio = {"lok","elen","orc","elv","arth","ob"};
   	private String[] orcish = {"ur","og","ag","un"};
   	private String[] elvish = {"il","al","el","in","ir"};
   	
    
    /**
	 * @return the silabas
	 */
	public Integer getSilabas() {
		return silabas;
	}

	/**
	 * @param silabas
	 */
	public void setSilabas(Integer silabas) {
		this.silabas = silabas;
	}
	
	 public Integer getRaza() {
			return raza;
	}

	public void setRaza(Integer raza) {
			this.raza = raza;
	}


	@Override
    public String execute()
    {

			if(raza == 1){
				Random random = new Random();			
				for(int i=0;i<silabas.byteValue();i++){				
					name += inicio[random.nextInt(inicio.length)];
				}
				name += elvish[random.nextInt(elvish.length)];
			}else{
				Random random = new Random();			
				for(int i=0;i<silabas.byteValue();i++){				
					name += inicio[random.nextInt(inicio.length)];
				}
				name += orcish[random.nextInt(orcish.length)];
			}
			
		return SUCCESS;
    }
           
    /**
     * 
     * @return result
     */
    public String getName (){
    	return name;
    } 
    
}